package com.coocaa.ops.admin.v1.mergeposter;

import com.coocaa.ops.admin.v1.mergeposter.service.IRefreshPosterMergeService;
import com.coocaa.ops.common.core.base.model.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author bjh
 * @description
 * @date 2021/1/7 10:52
 */
@RestController
@RequestMapping("/v1/mergePoster")
public class PosterMergeController {
    @Autowired
    private IRefreshPosterMergeService refreshPosterMergeService;

    /**
     * 刷新板块合成海报-根据板块组id和版本
     *
     * @param request
     * @param id
     * @param version
     * @return
     */
    @RequestMapping(value = "refreshPanelPosterMerge")
    public Object refreshPanelPosterMerge(HttpServletRequest request, @RequestParam Integer id,
                                          @RequestParam(required = false) Integer version,
                                          @RequestParam(required = false) Boolean checkHasMergePoster) {
        if (null == checkHasMergePoster) {
            checkHasMergePoster = true;
        }
        refreshPosterMergeService.refreshPanelPosterMerge(id, version, checkHasMergePoster);
        return R.ok();
    }

    /**
     * 重置板块合成海报-根据板块组id和版本
     *
     * @param request
     * @param id
     * @param version
     * @return
     */
    @RequestMapping(value = "resetPanelPosterMerge")
    public Object resetPanelPosterMerge(HttpServletRequest request, @RequestParam Integer id, @RequestParam(required = false) Integer version) {
        refreshPosterMergeService.resetPanelPosterMerge(id, version);
        return R.ok();
    }

    /**
     * 重置推荐位合成海报-根据推荐位id
     *
     * @param request
     * @param id
     * @return
     */
    @RequestMapping(value = "resetBlockPosterMerge")
    public Object resetBlockPosterMerge(HttpServletRequest request, @RequestParam Integer id) {
        refreshPosterMergeService.resetBlockPosterMerge(id);
        return R.ok();
    }
}
